package GUI;

import Kernel.Billet;
import Kernel.Client;
import Kernel.ProfilPassager;
import Kernel.Trajet;

public class Etape2_Train extends javax.swing.JFrame {
    

	private static final long serialVersionUID = 1L;
	private Trajet t;
	private Client ct;
    
	/** Crée une nouvelle instance de Etape2_Train */
    public Etape2_Train() {
    	initComponents();
        t = new Trajet();
        ct = new Client();
        this.setLocationRelativeTo(this.getParent());
    }
    
    /**
     * Crée une nouvelle instance de Etape2_Train
     * @param t  représente le trajet sélectionné avant
     */
    public Etape2_Train(Trajet t){
    	initComponents();
        this.t = t;
        ct = new Client();
        t.setTypeDeBase("Modifiable");
        this.jTextField_infoType.setText(t.getTypeDeBase());
        this.jTextField_infoType.setEditable(false);
        if(this.jTextField_infoType.getText().compareTo("Non modifiable")==0)
        		this.jCheckBox_modif.setEnabled(true);
        else this.jCheckBox_modif.setEnabled(false);
        this.setLocationRelativeTo(this.getParent());
    }
    
    /**
	 * Initialisation des composants d'AWT.
	 */                      
    private void initComponents() {

        jLabel_type = new javax.swing.JLabel();
        jCheckBox_modif = new javax.swing.JCheckBox();
        jLabel_classe = new javax.swing.JLabel();
        jComboBox_classe = new javax.swing.JComboBox();
        jCheckBox_repas = new javax.swing.JCheckBox();
        jCheckBox_fidelite = new javax.swing.JCheckBox();
        jCheckBox_cabine = new javax.swing.JCheckBox();
        jButton_suivant = new javax.swing.JButton();
        jLabel_etape2 = new javax.swing.JLabel();
        jTextField_infoType = new javax.swing.JTextField();
        jComboBox_typePassager = new javax.swing.JComboBox();
        jButton_retour = new javax.swing.JButton();
        jLabel_typeP = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel_type.setText("Type de billet proposé :");

        jCheckBox_modif.setText("Rendre modifiable");
        jCheckBox_modif.setEnabled(false);

        jLabel_classe.setText("Classe :");

        jComboBox_classe.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seconde", "Première" }));

        jCheckBox_repas.setText("Repas");

        jCheckBox_fidelite.setText("Carte de fidélité");

        jCheckBox_cabine.setText("Cabine");

        jButton_suivant.setText("Suivant");
        jButton_suivant.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_suivantActionPerformed(evt);
            }
        });

        jLabel_etape2.setText("Etape 2 - Bateau :");

        jComboBox_typePassager.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Adulte", "Enfant", "Enfant non-accompagné", "Etudiant", "Jeune", "Senior" }));

        jButton_retour.setText("Retour");
        jButton_retour.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_retourActionPerformed(evt);
            }
        });

        jLabel_typeP.setText("Type de passager :");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel_etape2)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel_type)
                                    .addGap(26, 26, 26)
                                    .addComponent(jTextField_infoType, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(57, 57, 57))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addComponent(jButton_retour)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                            .addComponent(jComboBox_typePassager, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel_classe)
                            .addComponent(jComboBox_classe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jCheckBox_repas)
                            .addComponent(jCheckBox_fidelite)
                            .addComponent(jCheckBox_cabine)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jButton_suivant)
                                .addComponent(jCheckBox_modif))))
                    .addComponent(jLabel_typeP))
                .addContainerGap(54, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel_etape2)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_type)
                    .addComponent(jTextField_infoType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCheckBox_modif))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel_typeP, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBox_typePassager, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(83, 83, 83)
                        .addComponent(jCheckBox_repas)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jCheckBox_fidelite)
                        .addGap(18, 18, 18)
                        .addComponent(jCheckBox_cabine)
                        .addGap(52, 52, 52)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton_suivant)
                            .addComponent(jButton_retour)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addComponent(jLabel_classe)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBox_classe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(33, Short.MAX_VALUE))
        );

        pack();
    }                       

                                          

    private void jButton_suivantActionPerformed(java.awt.event.ActionEvent evt) {
    	// On enregistre les différentes informations dans un billet
    	Billet billet;
    	String typePassager = jComboBox_typePassager.getSelectedItem().toString();
    	if(typePassager.compareTo("Enfant non-accompagné") == 0){
    		billet = new Billet(ProfilPassager.valueOf("ENFANT_NON_ACCOMPAGNE"), ct ,  t);
    	}
    	else {
    		billet = new Billet(ProfilPassager.valueOf(typePassager.toUpperCase()), ct ,  t);
    	}
    	// Première classe
        if(jComboBox_classe.getSelectedItem().toString().compareTo("Première") == 0){
        	billet.setPremiereClasse(true);
        }
        // Repas
        billet.setRepas(jCheckBox_repas.isSelected());
        // Carte de fidélité
        billet.setCarteFidelite(jCheckBox_fidelite.isSelected());
        
        // On affiche la fenêtre suivante
        Bilan b = new Bilan(this.t,billet);
        this.setVisible(false);
        b.setVisible(true);
    }                                               

    private void jButton_retourActionPerformed(java.awt.event.ActionEvent evt) {                                               
    	Etape11 e = new Etape11();    	
    	e.setVisible(true);
    	this.setVisible(false);
        this.dispose();
    }                                              
    
    
    private javax.swing.JButton jButton_retour;
    private javax.swing.JButton jButton_suivant;
    private javax.swing.JCheckBox jCheckBox_cabine;
    private javax.swing.JCheckBox jCheckBox_fidelite;
    private javax.swing.JCheckBox jCheckBox_modif;
    private javax.swing.JCheckBox jCheckBox_repas;
    private javax.swing.JComboBox jComboBox_classe;
    private javax.swing.JComboBox jComboBox_typePassager;
    private javax.swing.JLabel jLabel_classe;
    private javax.swing.JLabel jLabel_etape2;
    private javax.swing.JLabel jLabel_type;
    private javax.swing.JLabel jLabel_typeP;
    private javax.swing.JTextField jTextField_infoType;         
    
}
